<html>
	<head>
		<title>
			Wikipedia Article Grabber Demo
		</title>
		<script src="../../../dojo/dojo.js" type="text/javascript"
			data-dojo-config="parseOnLoad: true, isDebug: true"></script>
		<script type="text/javascript">
			dojo.require("dojo.io.script")
			dojo.require("dojox.rpc.Service");
			dojo.require("dijit._Widget");
			dojo.require("dojox.dtl._Templated");
			dojo.require("dojo.parser");

			dojo.declare("WikipediaPageGrabber", [dijit._Widget, dojox.dtl._Templated], {
				constructor: function(params, node){
					var mu = dojo.moduleUrl("dojox.rpc.SMDLibrary", "wikipedia.smd");
					this.wikipedia = new dojox.rpc.Service(mu);
				},
				onSearch: function(e){
					if(e.keyCode == dojo.keys.ENTER){
						this.wikipedia.query({
							action: "parse",
							page: e.target.value
						}).addCallback(this, function(article){
							console.debug(article.parse);
							this.article = article.parse;
							this.parsedText = article.parse.text["*"]; // ugh, crazy JSON structure here
							this.render();
						});
					}
				},
				templateString: dojo.cache("dojox.rpc.demos.templates", "wikipedia.html")
			});
		</script>
	</head>
	<body>
		<h1>Wikipedia Page Grabber</h1>
		<div dojoType="WikipediaPageGrabber"></div>
	</body>
</html>
